/*
 *@description: 小数转换---加法
 *@author: administrator
 *@date: 2021-09-17 10:06:38
 *@version: V1.0.5
 */
export function add(num1, num2) {
    let sq1, sq2, m;
    try {
        sq1 = num1.toString().split('.')[1].length
    } catch (e) {
        sq1 = 0
    }
    try {
        sq2 = num2.toString().split('.')[1].length
    } catch (e) {
        sq2 = 0
    }
    m = Math.pow(10, Math.max(sq1, sq2)) * 10
    return (num1 * m + num2 * m) / m
}
/*
 *@description: 小数转换---减法
 *@author: administrator
 *@date: 2021-09-17 10:06:38
 *@version: V1.0.5
 */
export function sub(num1, num2) {
    let sq1, sq2, m, n;
    try {
        sq1 = num1.toString().split('.')[1].length
    } catch (e) {
        sq1 = 0
    }
    try {
        sq2 = num2.toString().split('.')[1].length
    } catch (e) {
        sq2 = 0
    }
    m = Math.pow(10, Math.max(sq1, sq2));
    n = (sq1 >= sq2) ? sq1 : sq2;
    return ((num1 * m - num2 * m) / m).toFixed(n);
}
/*
 *@description: 小数转换---乘法
 *@author: administrator
 *@date: 2021-09-17 10:06:38
 *@version: V1.0.5
 */

export function mul(num1, num2) {
    let temp = 0
    try {
        temp += num1.toString().split('.')[1].length
    } catch (e) {

    }
    try {
        temp += num2.toString().split('.')[1].length
    } catch (e) {}

    return Number(num1.toString().replace(".", "")) * Number(num2.toString().replace(".", "")) / Math.pow(10, temp);

}

/*
 *@description: 小数转换---除法
 *@author: administrator
 *@date: 2021-09-17 10:06:38
 *@version: V1.0.5
 */

export function div(num1, num2) {
    let sq1, sq2, temp, int1 = 0,
        int2 = 0;
    try {
        sq1 = num1.toString().split('.')[1].length
    } catch (e) {
        sq1 = 0
    }
    try {
        sq2 = num2.toString().split('.')[1].length
    } catch (e) {
        sq2 = 0
    }

    int1 = Number(num1.toString().replace(".", ""))
    int2 = Number(num2.toString().replace(".", ""))
    return (int1 / int2) * Math.pow(10, sq2 - sq1);


}